<h1>Todo List <%= @todo_list.name %>
  <p>Last Updated at: <%=h @todo_list.updated_at %>
  <h2>Deliverables</h2>


<% form_tag :action => 'move_to_most_recent_iteration' do %>
  <%= hidden_field_tag 'todo_list_id', @todo_list.id %>
  <table width = "75%" border = 1>
    <th></th>
    <th align="left">Release Name</th>
    <th align="left">Product Name</th>
    <th align="left">Feature Name</th>
    <th align="left">Description</th>
    <th align="left">Resources</th>
    <th align="center"></th>
    <% deliverable_number = 1 %>

  <% for deliverable in @deliverables %>
  <tr>
    <td>
      <%= deliverable_number %>
    </td>
    <td>
      <%= deliverable.project.name unless !deliverable.project %>
    </td>
    <td>
      <%= deliverable.product.name unless !deliverable.product %>
    </td>
    <td>
      <%= deliverable.feature.name unless !deliverable.feature %>
    </td>
    <td>
      <%= link_to deliverable.description, {
            :controller => :deliverables,
            :action => :edit,
            :id => deliverable.id
            }, {
            :class => :data
            } %>
  </td>
  <td>
    <% for assignment in deliverable.assignments %>
      <%= Resource.format_name(assignment.resource.name)  %>
    <% end %>
  </td>
  <td>
    <%= check_box_tag 'deliverableIds[]', deliverable.id %>
  </td>
</tr>
  <% deliverable_number = deliverable_number + 1  %>
  <% end %>

  <tr>
    <td>
      <%= deliverable_number %>
    </td>
    <td colspan="3"><i>
        <%= link_to "Add new deliverable", {
              :controller => :deliverables,
              :action => :new,
              :schedulable_id =>@todo_list.id,
              :schedulable_type => "TodoList"
              }, {
              :class => :command 
              }%>
      </i></td>
</tr>

</table>
<br>
<%= submit_tag "Move to current iteration" %>
<% end %>

<br>
<%= link_to 'Edit', :action => 'edit', :id => @todo_list %> |
<%= link_to 'Back', :action => 'list' %>
